﻿using behaviors.Controllers;
using FubuMVC.Core;
using FubuMVC.Core.Behaviors;
using FubuMVC.Core.Runtime;

namespace behaviors.Behaviors
{
    public class FooterTextBehavior<TOutput>
        : BasicBehavior
        where TOutput : class, IFooter
    {
        private readonly IFubuRequest request;
        private readonly FooterSettings footerSettings;

        public FooterTextBehavior(IFubuRequest request, FooterSettings footerSettings) 
            : base(PartialBehavior.Executes)
        {
            this.request = request;
            this.footerSettings = footerSettings;
        }

        protected override DoNext performInvoke()
        {
            var output = request.Get<TOutput>();
            output.FooterText = footerSettings.Text;

            return DoNext.Continue;
        }
    }

    public class FooterSettings
    {
        public string Text { get; set; }
    }
}